package com.lc.afbx;

import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.util.Log;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.tencent.bugly.crashreport.CrashReport;
import com.zcx.helper.app.AppApplication;
import com.zcx.helper.http.Http;
import com.zcx.helper.http.note.HttpInlet;
import com.zcx.helper.init.Helper;
import com.zcx.helper.scale.ScaleScreenHelper;
import com.zcx.helper.scale.ScaleScreenHelperFactory;
import com.zcx.helper.util.UtilAsyncListBitmap;

import java.util.concurrent.TimeUnit;

public class BaseApplication extends AppApplication {

    public static ScaleScreenHelper ScaleScreenHelper;

    public static UtilAsyncListBitmap UtilAsyncListBitmap;

    public static BasePreferences BasePreferences;

    @Override
    public void onCreate() {

        super.onCreate();

        Helper.Initialize(this, "AnFengBaoXianAndroid");

        Http.getInstance().setIsLog(true);

        Http.getInstance().setWriteTimeout(20, TimeUnit.SECONDS);

//        Http.getInstance().setConnectTimeout(20, TimeUnit.SECONDS);

//        Http.getInstance().setReadTimeout(20, TimeUnit.SECONDS);

        Http.getInstance().setRetryOnConnectionFailure(true);

        Http.getInstance().setOnStartEndCreateDialog(new Http.OnStartEndCreateDialog() {

            @Override
            public Dialog onCreate(Context context) {

                return new ProgressDialog(context);

            }

            @Override
            public void show(Dialog dialog) {

                dialog.setCanceledOnTouchOutside(false);
                dialog.show();

            }

            @Override
            public void dismiss(Dialog dialog) {

                dialog.dismiss();

            }

        });

        ScaleScreenHelper = ScaleScreenHelperFactory.create(this, 720);

        UtilAsyncListBitmap = new UtilAsyncListBitmap(this, "afbx", R.id.default_id, R.mipmap.ic_launcher);

        BasePreferences = new BasePreferences(this, "afbx");

        RequestManager.createInstance(getApplicationContext());
        Log.d("nihao", "RequestManager被创建了");

        Fresco.initialize(this);

        CrashReport.initCrashReport(getApplicationContext(), "23d27806b2", true);


    }

}
